<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>结算交易</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
		<link rel="stylesheet" href="../../../css/common.css" media="all">
	</head>

	<body>
		<div class="layui-fluid">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-body">
							<!-- 搜索 -->
							<form class="layui-form search" id="form" onsubmit="return false" action="##">
								<div class="layui-inline search_inline">
									<label class="layui-form-label">时间段：</label>
									<div class="layui-input-inline" style="width: 300px;">
										<input class="layui-input" id="choosetime" placeholder="时间段" autocomplete="off">
										<input class="layui-input" type="text" id="starttime" name="starttime"
											placeholder="" autocomplete="off" style="display: none;">
										<input class="layui-input" type="text" id="endtime" name="endtime"
											placeholder="" autocomplete="off" style="display: none;">
									</div>
								</div>
								<div class="layui-inline search_inline">
									<label class="layui-form-label">应用编号：</label>
									<div class="layui-input-inline">
										<input class="layui-input" lay-verify="" placeholder="应用编号"
											name="app_id" id="settle_trans_app_id" autocomplete="off">
									</div>
								</div>
								<div class="layui-inline search_inline">
									<label class="layui-form-label">订单号：</label>
									<div class="layui-input-inline">
										<input class="layui-input" lay-verify="" placeholder="订单号" name="order_no"
											id="order_no" autocomplete="off">
									</div>
								</div>
								<div class="layui-inline search_inline">
									<label class="layui-form-label">取现类型：</label>
									<div class="layui-input-inline">
										<input class="layui-input" lay-verify="" placeholder="取现类型" name="cash_type"
											id="cash_type" autocomplete="off">
									</div>
								</div>
								<div class="layui-inline search_inline">
									<label class="layui-form-label">用户号：</label>
									<div class="layui-input-inline">
										<input class="layui-input" lay-verify="" placeholder="用户号" name="member_id"
											id="member_id" autocomplete="off">
									</div>
								</div>
								<div class="layui-inline search_inline">
									<label class="layui-form-label">姓名：</label>
									<div class="layui-input-inline">
										<input class="layui-input" lay-verify="" placeholder="姓名" name="card_name" autocomplete="off">
									</div>
								</div>
								<div class="layui-inline search_inline">
									<label class="layui-form-label">身份证号：</label>
									<div class="layui-input-inline">
										<input class="layui-input" lay-verify="" placeholder="银行卡号" name="cert_no" autocomplete="off">
									</div>
								</div>
								<div class="layui-inline search_inline">
									<label class="layui-form-label">银行卡号：</label>
									<div class="layui-input-inline">
										<input class="layui-input" lay-verify="" placeholder="银行卡号" name="card_no" autocomplete="off">
									</div>
								</div>
								<div class="layui-inline search_inline">
									<label class="layui-form-label" >状态：</label>
									<div class="layui-input-inline">
										<select name="status" lay-verify="" id="status-select">
											<option value="">全部</option>
											<option value="-1">请求失败</option>
											<option value="0">失败</option>
											<option value="1">处理中</option>
											<option value="2">成功</option>
										</select>
									</div>
								</div>
								<button class="layui-btn search_inline" lay-submit="" lay-filter="search"
									data-type="reload" id="searchBtn">搜索</button>
								<button class="layui-btn layui-btn-primary search_inline" type="reset">重置</button>
							</form>
							<!-- 搜索 -->
							<table class="layui-hide" id="test-table-operate" lay-filter="test-table-operate"></table>
							<script type="text/html" id="test-table-operate-barDemo1">
							{{# if(d.status != 1){ }}
								<a class="layui-btn layui-btn-default layui-btn-xs" lay-event="audit">审核</a>
								{{# } }}
									<a class="layui-btn layui-btn-xs" lay-event="edit">修改</a>
									<!-- 				<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
								<a class="layui-btn layui-btn-xs" lay-event="edit">修改</a> 
								{{# if(d.status == 1){ }}
									<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="disable">禁用</a>
								{{# } }} -->

							</script>
						</div>
					</div>
				</div>
			</div>
		</div>

		<script src="../../../layuiadmin/layui/layui.js"></script>
		<script src="../../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../../js/common.js"></script>
		<script>
			var _data = {
				// parent_id: getParam('id'),  
				btype: 1
			}
			layui.config({
				base: '../../../layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'table', 'form', 'treeGrid'], function() {
				var table = layui.table,
					$ = layui.$,
					form = layui.form,
					laydate = layui.laydate,
					treeGrid = layui.treeGrid,
					admin = layui.admin;
				laydate.render({
					elem: '#choosetime',
					type: 'datetime',
					range: true,
					value: '',
					done: function(value, date) {
						$('input[name=starttime]').val(value.split(' - ')[0]);
						$('input[name=endtime]').val(value.split(' - ')[1]);
					}
				});
				
			if ($('#choosetime').val() !== '') {   // 判断 value 参数是否为空字符串
			  $("#starttime").val(getstartime());
			  $("#endtime").val(getendtime());
			  var _data = {
			    starttime: $("#starttime").val(),
			    endtime: $("#endtime").val(),
			  };
			}
				initdata();

				function getstartime() {
					var today = new Date();
					var tYear = today.getFullYear();
					var tMonth = today.getMonth() + 1;
					var tDate = today.getDate();
					tMonth = doHandleMonth(tMonth)
					tDate = doHandleMonth(tDate)
					return tYear + "-" + tMonth + "-" + tDate + "-00-00-00";
				}

				function getendtime() {
					var today = new Date();
					var tYear = today.getFullYear();
					var tMonth = today.getMonth() + 1;
					var tDate = today.getDate();
					tMonth = doHandleMonth(tMonth)
					tDate = doHandleMonth(tDate)
					return tYear + "-" + tMonth + "-" + tDate + "-23-59-59";
				}

				function doHandleMonth(month) {
					var m = month;
					if (month.toString().length == 1) {
						m = "0" + month;
					}
					return m;
				}

				function initdata() {
					table.render({
						elem: '#test-table-operate',
						url: server.sys_settle_trans_query,
						height: 'full-115',
						cellMinWidth: cellMinWidth,
						limit: limit,
						limits: limits,
						defaultToolbar: [  'exports', {
							title: '提示' //标题
							, layEvent: 'LAYTABLE_TIPS' //事件名，用于 toolbar 事件中使用
							, icon: 'layui-icon-tips' //图标类名
						}],
						toolbar: true,
						cols: [
							[{
									width: 70,
									type: 'numbers',
									title: '序号',
									fixed: 'left',
								},
								{
									field: 'app_id',
									title: '应用编号',
									width: 350,
									event: 'app_id'
								}, {
									field: 'order_no',
									title: '订单号',
									width: 200,
									event: 'order_no',
								}, {
									field: 'cash_type',
									width: 200,
									title: '出款方式'
								},
								{
									field: 'cash_amt',
									width: 200,
									title: '交易金额',
									sort: true
								},
								{
									field: 'fee_amt',
									width: 180,
									title: '服务费'
								},

								{
									field: 'member_id',
									width: 180,
									title: '用户号',
									event: 'member_id'
								},
								{
									field: 'card_name',
									title: '姓名',
									event: 'card_name'
								},
								{
									field: 'cert_no',
									width: 200,
									title: '身份证号',
									event: 'cert_no',
									
								},
								{
									field: 'card_no',
									width: 200,
									title: '银行卡号',
									event: 'card_no'
								},

								{
									field: 'status',
									width: 180,
									title: '状态'
								},
								{
									field: 'status_msg',
									width: 180,
									title: '状态描述'
								},
								{
									field: 'results',
									width: 180,
									title: '返回结果'
								},
								{
									field: 'notify_results',
									width: 180,
									title: '回调结果'
								},
								{
									field: 'addtime',
									title: '添加时间',
									width: 200,
								}, {
									field: 'edittime',
									title: '修改时间',
									width: 200,
								}
							]
						],
						page: true,
						where: _data,
						request: {
							pageName: 'page',
							limitName: 'size',
						},
						parseData: function(res) { //将原始数据解析成 table 组件所规定的数据
							console.log("这是数据", res);
							let shopdata = res.settle_trans.data
							return {
								"code": res.code, //解析接口状态
								"msg": res.msg, //解析提示文本
								"count": res.settle_trans.pager.total, //解析数据长度
								"data": res.settle_trans.data //解析数据列表
							};
						}
					});
				}

				//监听表格单击事件
				table.on('tool(test-table-operate)', function (obj) {
					console.log(obj)
					var key = obj.event
					if (!key) {
						return
					}
					var queryData = obj.data[key]
					$('input[name="' + key + '"]').val(queryData)
					//$("#searchBtn").click()
				});

				$('#add').on('click', function() {
					layer.open({
						type: 2,
						title: '添加',
						shadeClose: true,
						shade: 0.5,
						maxmin: true, //开启最大化最小化按钮
						area: ['750px', '700px'],
						content: 'model/edit_add.html?customerid=' + $("#customerid").val(),
						end: function() {

						}
					});
				});

				//监听搜索
				form.verify({
					memberid: function(value, item) { //value：表单的值、item：表单的DOM对象
						if (!value) {
							return '姓名不能为空';
						}
					}
				});

				//监听搜索
				form.on('submit(search)', function(data) {
					_data = data.field
					initdata();
					return false;
				});

				$("button[type=reset]").on("click", function() {
					_data = {}
					document.getElementById("form").reset();
					setTimeout(() => {
						$("#choosetime").val(getstartime() + ' - ' + getendtime())
						$("#starttime").val(getstartime())
						$("#endtime").val(getendtime())
						_data.starttime = $("#starttime").val()
						_data.endtime = $("#endtime").val()
						initdata();
					}, 100)
				});

				//监听表格复选框选择
				table.on('checkbox(test-table-operate)', function(obj) {
					console.log(obj)
				});

				

				var $ = layui.$,
					active = {
						getCheckData: function() { //获取选中数据
							var checkStatus = table.checkStatus('test-table-operate'),
								data = checkStatus.data;
							layer.alert(JSON.stringify(data));
						},
						getCheckLength: function() { //获取选中数目
							var checkStatus = table.checkStatus('test-table-operate'),
								data = checkStatus.data;
							layer.msg('选中了：' + data.length + ' 个');
						},
						isAll: function() { //验证是否全选
							var checkStatus = table.checkStatus('test-table-operate');
							layer.msg(checkStatus.isAll ? '全选' : '未全选')
						}
					};

				$('.test-table-operate-btn .layui-btn').on('click', function() {
					var type = $(this).data('type');
					active[type] ? active[type].call(this) : '';
				});

				function getstartime() {
					var today = new Date();
					var tYear = today.getFullYear();
					var tMonth = today.getMonth() + 1;
					var tDate = today.getDate();
					tMonth = doHandleMonth(tMonth)
					tDate = doHandleMonth(tDate)
					return tYear + "-" + tMonth + "-" + tDate + " 00:00:00";
				}

				function getendtime() {
					var today = new Date();
					var tYear = today.getFullYear();
					var tMonth = today.getMonth() + 1;
					var tDate = today.getDate();
					tMonth = doHandleMonth(tMonth)
					tDate = doHandleMonth(tDate)
					return tYear + "-" + tMonth + "-" + tDate + " 23:59:59";
				}

				function doHandleMonth(month) {
					var m = month;
					if (month.toString().length == 1) {
						m = "0" + month;
					}
					return m;
				}
			});

			function seeimg(url) {
				//alert();
				var img_data = {
					"data": [{
						"src": url
					}]
				}
				layer.photos({
					photos: img_data,
					anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
				});
			}
		
		</script>
	</body>

</html>